<script setup>
import * as echarts from 'echarts';
import { ref, onMounted, onUpdated } from 'vue';

const props = defineProps({
  option: Object,
});

const el = ref(null);

let chartInstance = null;

onMounted(() => {
  chartInstance = echarts.init(el.value);
  chartInstance.setOption(props.option);
});

onUpdated(() => {
  chartInstance.setOption(props.option);
});

</script>

<template>
  <div ref="el" class="chart" />
</template>

<style>
.chart {
  height: 100%;
  width: 100%;
}
</style>
